<?php
if (!defined('SITE_TOP_PATH')) {
	exit ('Access Denied');
}
define('CURACTION', dirname(__FILE__));

Basic :: initApp();
$gModel = Basic :: getModel();
$gAction = Basic :: getAction();

$_default_act = MODEL_PATH  . '/default/404.php';

if ($gModel == 'admin') {
	include CONFIG_PATH . '/' . APP_NAME . '_menu.php';
	include LIB_PATH . 'menu.php';

	$menu = new Menu;

	if(empty($_SESSION['sys']['id'])){
		$gAction ='login';
	}else {
		$_username = $_SESSION['sys']['username'];
		if($_username != 'admin') {
			$_userMenu = $menu->getMenu($_username);
		}else {
			$_userMenu = $_menus;
		}
		if(!$menu->check($gModel, $gAction, $_userMenu)) {
			$gAction ='login';
			Basic::flash($tpl->lang('No Permission.'));
		}

	}
}

$_action = MODEL_PATH . $gModel . '/' . $gAction . '.php';

// 引入action
$_action = is_file($_action) ? $_action : $_default_act;
require_once ($_action);
?>